package com.acme.stocksanalisis;


import com.acme.business.StockBusiness;
import com.acme.model.Stock;
import com.acme.persistence.StockDao;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class StartApp {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

            Stock stock = new Stock();
            stock.setName("Google");
            stock.setSymbol("GOOG");
            stock.setSumary("Esto es la desc");
System.out.println("XZCKZXCLXZCZXCZXKCXZKCKZXCKXZCK");
            ApplicationContext context = new ClassPathXmlApplicationContext("/mvc-dispatcher-servlet.xml");

            StockBusiness stockBusiness = (StockBusiness) context.getBean("stockBusiness");

            doWork(stockBusiness);

            StockDao stockDao = (StockDao) context.getBean("stockDao");
            stockBusiness.setStockDao(stockDao);
            //stockBusiness.createStock("TS.BA", "Tenaris", "este es el sumario");
            doWork(stockBusiness);
		
	}

	private static void doWork(StockBusiness stockBusiness) {
            System.out.println("====== Do Work ======"); 

            System.out.println("alumno id 1: " + stockBusiness.getStock(1));

            for (Stock s : stockBusiness.getAllStocks()) {
                    System.out.println(s.getName());
                    System.out.println(s.getSumary());
                    System.out.println(s.getSymbol());
            }
            System.out.println("======  ======  ======");
	}
}
